<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>DOM和BOM</title>
</head>
<body>
  <div id="div1" class="class-div1">
    <div class="pwrap">
      <p id="p1" data-name="p1-data-name">this is p1</p>
    </div>
    <p id="p2">this is p2</p>
  </div>
  <div id="div2">
    <p id="p3">this is p3</p>
    <p id="p3">this is p4</p>
  </div>
  <script>
    // property
    var div1 = document.getElementById('div1')
    console.log(div1.className)
    div1.className = 'abc'
    console.log(div1.className)
    var newP = document.createElement('p')
    newP.innerHTML = 'this is new p'
    div1.appendChild(newP)
    // attribute
    var p1 = document.getElementById('p1')
    console.log(p1.getAttribute('data-name'))
    var parent = p1.parentElement
    console.log(parent)
    // p1.innerHTM L = 'update innerHTML content'
    
    console.log(div1.childNodes)
    console.log(div1.childNodes[0].nodeType)
    console.log(div1.childNodes[1].nodeType)
    console.log(navigator.userAgent)
    console.log(location)
    console.log(location.search)
    console.log(location.hash)
    

  </script>
</body>
</html>